CC = gcc -I..
CXX = g++ -I..
#OPT = -g
OPT = -g -Wall -O3

# Determine the OS we're running on
OSTYPE := $(shell uname)

#
# LINUX SECTION
#
ifneq (,$(findstring Linux,$(OSTYPE)))
DL = -ldl
DLFLAGS = -fpic -shared -Wl,--export-dynamic
endif

#
# MAC OSX SECTION
#
ifneq (,$(findstring Darwin,$(OSTYPE)))
DL = -ldl
DLFLAGS = -fPIC -bundle -undefined dynamic_lookup
endif

#
# CYGWIN SECTION
#
ifneq (,$(findstring cygwin,$(OSTYPE))$(findstring CYGWIN,$(OSTYPE)))
DL =
DLFLAGS = -shared -Wl,--export-dynamic
endif


DYN_OBJS = ./slide15_0.so  ./slide15_7.so ./slide15_8.so  ./slide15_9.so \
	   ./slide15_10.so ./slide15_11.so ./slide15_12.so \
	   ./slide15_13.so ./slide15_14.so

all: $(DYN_OBJS)

%.c: %.psvn ../psvn2c ../psvn2c_common.c
	cd .. && ./psvn2c --name=$(*F) --backwards_moves < slide15/$< > slide15/$@

%.so: %.c ../psvn_game_so.h
	$(CC) $(OPT) $(DLFLAGS) $< $(DL) -o $@

clean:
	rm *.so
